<template>
    <x-popup v-model="showModal" top="30vh">
        <view class="flex flex-center px-4">
            <view class="flex-1 h8 font-weight-600 p-10 text-center">快速登录</view>
        </view>
        <x-login-form ref="xLoginFormRef" @success="success" @fail="hide" @wx-login="wx_login" />
    </x-popup>
</template>

<script setup lang="ts">
import { ref, nextTick } from "vue";
import { wxLogin } from "@/utils";
const showModal = ref(false);
const wxOptions = ref({});
const emit = defineEmits(['success']);
const xLoginFormRef = ref();
const show = (options:any) => {
    if (options) {
        wxOptions.value = options
    }
    showModal.value = true;
    nextTick(() => {
        xLoginFormRef.value?.show();
    })
}
const hide = () => {
    showModal.value = false;
}
const success = () => {
    hide();
    emit('success');
}
const wx_login = () => {
    wxLogin(wxOptions.value)
}
defineExpose({
    show
})
</script>

<style lang="scss" scoped>
.w-100px {
    width: 100px;
}
</style>